package com.tjcd.project.library_base.push.mqtt;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.work.Worker;
import androidx.work.WorkerParameters;

/**
 * @Author jiangKunKun
 * @CreateDate 2025/3/6
 * @Description
 * @SpittingGrooves
 */
public class MqttWorker extends Worker {
    private MqttManager mqttManager;

    public MqttWorker(@NonNull Context context, @NonNull WorkerParameters params) {
        super(context, params);
        mqttManager = MqttManager.getInstance();
    }

    @NonNull
    @Override
    public Result doWork() {
        try {
            mqttManager.connectMqtt();
        } catch (Exception e) {
            // 表示任务执行失败，WorkManager 会根据配置重试该任务。
            return Result.retry();
        }
        return Result.success();
    }

}
